import { ref } from 'vue'
import { defineStore } from 'pinia'

export const useUserStore = defineStore(
  'user',
  () => {
    // 存储用户信息
    const UserList = ref({})

    // 将获取到的用户信息和token存入本地
    const setUserList = (data) => {
      UserList.value = data
    }

    // 退出登录时清空个人信息
    const clearUserList = () => {
      UserList.value = {}
    }

    return {
      UserList,
      setUserList,
      clearUserList
    }
  },
  {
    persist: true
  }
)
